package mGraph;

import java.io.Serializable;


/**
 * 
 * @author Giulio Rossetti
 *
 */
public class MTEdge implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6592408053205697348L;
	protected int y=-1, x=-1, d;
	protected byte[] timestamp;
	
	
	/**
	 * Create a simple undirected edge between the nodes labeled with x and y
	 * 
	 * @param x Identifier of a node
	 * @param y Identifier of a node
	 */
	public MTEdge(int x,int y){
		this.x=x;
		this.y=y;
	}
	
	
	/**
	 * Create an undirected edge between the nodes labeled with x and y in on the dimension d
	 * 
	 * @param x Identifier of a node
	 * @param y Identifier of a node
	 * @param d Identifier of a dimension
	 * @param timestamp 
	 */
	public MTEdge(int x,int y,int d, byte[] timestamp){
		this.x=x;
		this.y=y;
		this.d=d;
		this.timestamp=timestamp;
	}
	
	public byte[] getTimestampedAppareance(){
		return this.timestamp;
	}
	
	/**
	 * Return the first endpoint of the edge
	 * 
	 * @return Identifier of a node
	 */
	public int getX(){
		return this.x;
	}

	/**
	 * Return the second endpoint of the edge
	 * 
	 * @return Identifier of a node
	 */
	public int getY(){
		return this.y;
	}
	
	
	public int getDimension(){
		return this.d;
	}
	
	/**
	 * 
	 */
	public boolean equals(Object o){
		MTEdge e = (MTEdge) o;
				
		if(e.x==this.x && e.y==this.y){
			return true;
		}
		
		else return false;
	}

	
	/**
	 * 
	 */
	public String toString(){
		if(this.x!=-1&&this.y!=-1){
			String res = "("+x+","+y+")";
			return res;
		}
		return "";
	}
	
}
